package org.example.testone.controller;

import org.example.testone.common.Result;
import org.example.testone.entity.WorkOrder;
import org.example.testone.service.WorkOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/post/order")
public class WorkOrderController {

    @Autowired
    private WorkOrderService workOderService;

    @PostMapping("/save")
    public Result save(@RequestBody WorkOrder workOrder) {
        return workOderService.save(workOrder);
    }

    @PostMapping("/update")
    public Result update(@RequestBody WorkOrder workOrder) {
        return workOderService.update(workOrder);
    }

    @GetMapping("/delete")
    public Result delete(@RequestParam(name = "id") int id) {
        return workOderService.delete(id);
    }

    @GetMapping("/search")
    public Result search(@RequestParam(name = "offset") int offset,
                         @RequestParam(name = "pageSize") int pageSize) {
        return workOderService.search(offset, pageSize);
    }

    @GetMapping("/fenpai")
    public Result fenpai(@RequestParam(name = "order_id") int order_id,
                         @RequestParam(name = "dept_id") int dept_id) {
        return workOderService.fenpai(order_id, dept_id);
    }

}
